<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<html:html lang="true">
    <head>
        <script type="text/javascript">
     // Popup window code


     function newPopup(url) {
         popupWindow = window.open(
		url, 'popUpWindow', 'height=500,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
     }
     function disableDefault(){
		document.getElementById("upload").disabled=true;
        }
      </script>
    </head>
    <body style="background-color: white" onload="disableDefault()">

       <html:form action="/insuranceFirstCheckUpdated">
           <p>First Cheque</p>
           <input type="file" id="file"   />


<script>


  function handleFileSelect(evt) {

    var files = evt.target.files; // FileList object

	//	hello();
    for (var i = 0, f; f = files[i]; i++) {



      var reader = new FileReader();

      reader.onload = (function(theFile) {
        return function(e) {

	im = new Image();

	im.src = e.target.result;
	var s=im.src;
	
        var pic="<a href=\"JavaScript:newPopup('"+s+"');\"><img src='"+s+"' width=100 height=100 name=\"pic\"/></a>";

	s="<textarea name=\"pic\" hidden=\"\">"+s+"</textarea>";
	outputdiv = document.getElementById('output');
	outputdiv.innerHTML =s;

	outputdiv = document.getElementById('pic');
	outputdiv.innerHTML =pic;
        document.getElementById("upload").disabled=false;

	    };
      })(f);
      reader.readAsDataURL(f);
    }
  }

  document.getElementById('file').addEventListener('change', handleFileSelect, false);
</script>

<div id="output"></div>
<div id="pic"><img src="" width="160" height="100"></div>
<%String activationCode=(String)session.getAttribute("activationCode");%>
<%
        String insuranceIdProof=(String)request.getParameter("insuranceIdProof");

%>
<input type="text" name="activationCode" value="<%out.print(activationCode);%>"hidden=""/>
<input type="text" name="insuranceIdProof" value="<%out.print(insuranceIdProof);%>"hidden=""/>

           <input type="submit" id="upload" value="Click To Upload Third Cheque Copy"/>


        </html:form>

    </body>
</html:html>
